<?php defined('SYSPATH') or die('No direct script access.');

// Настройки
class Model_Settings
{
    public function get_settings()
    {
        $query = DB::select()
                    ->from('settings');
                
        $settings = $query->execute()->as_array();

        return $settings; 
    }
    
    public function process_settings($tmp_settings)
    {
        $settings = array();
        foreach($tmp_settings as $setting)
        {
            $settings[$setting['key']] = $setting['value'];   
        }
        
        return $settings;   
    }
    
    public function update_setting($value, $key)
    {   
        $query = DB::update('settings')
                        ->set(array('value' => $value))
                        ->where('key', '=', $key);
                               
        $result = $query->execute();
        
        return $result;
    }
} // End Settings
